home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Camelot
/
Camelot 134 (1991-10)(Swedish User Group of Amiga)(SE)(PD)[WB].zip
/
Camelot 134 (1991-10)(Swedish User Group of Amiga)(SE)(PD)[WB].adf
/
RxSlides
/
color_util.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-08
|
2KB
|
85 lines
/* :bk=0 */
/************************************************************************/
/* */
/* Color_util.c */
/* */
/* Author: Lee M. Robertson and Dean Bandes */
/* Based on an article in the Nov '86 Doctor Dobb's Journal */
/* by Mike Morton */
/* */
/************************************************************************/
#include "exec/types.h"
#include "exec/memory.h"
#include "intuition/intuition.h"
#include "RxSlides.h"
static UWORD ColorTable[32];
/*---------------------------------------------------------------------------
* setcolors() -- set the color registers
*-------------------------------------------------------------------------*/
void setcolors( vp, creg, numcolors )
struct ViewPort *vp;
register UBYTE *creg; /* the color values */
int numcolors; /* the # of colors to set */
{
register ULONG r,g,b; /* the RGB color values (temporaries) */
register int i;
for(i=0; i<numcolors; i++)
{
r = *creg++ >> 4;
g = *creg++ >> 4;
b = *creg++ >> 4;
ColorTable[i] = ((r & 0x00f) << 8) |
((g & 0x00f) << 4) |
(b & 0x00f);
}
WaitTOF();
LoadRGB4(vp, ColorTable, numcolors);
}
/*---------------------------------------------------------------------------
*
*-------------------------------------------------------------------------*/
void fadecolors( vp, creg1, creg2, num, denom, numcolors)
struct ViewPort *vp;
register UBYTE *creg1, *creg2;
int num, denom, numcolors;
{
register ULONG r,g,b; /* the RGB color values (temporaries) */
register int i, diff;
if ( num > denom )
num = denom;
if ( num < 0 )
num = 0;
diff = denom - num;
for(i=0; i<numcolors; i++)
{
r = (((diff * (int) *creg1++) + (num * (int) *creg2++)) / denom) >> 4;
g = (((diff * (int) *creg1++) + (num * (int) *creg2++)) / denom) >> 4;
b = (((diff * (int) *creg1++) + (num * (int) *creg2++)) / denom) >> 4;
ColorTable[i] = ((r & 0x00f) << 8) |
((g & 0x00f) << 4) |
(b & 0x00f);
}
WaitTOF ();
LoadRGB4(vp, ColorTable, numcolors);
}
/*---------------------------------------------------------------------------
*
*-------------------------------------------------------------------------*/
void savecolors (dest, src)
UBYTE *dest, *src;
{
int i;
for (i=0; i<CMSIZE; i++)
*dest++ = *src++;
}